﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Quiz
{
    /// <summary>
    /// Interaktionslogik für QuizOptionen.xaml
    /// </summary>
    public partial class QuizOptionen : Window
    {
        private DataBase _db;

        /// <summary>
        /// Initialisieren der QuizOptionen
        /// </summary>
        public QuizOptionen()
        {

            InitializeComponent();

            _db = new DataBase();
            uxKategorienCb.DataContext = _db;
            this.DataContext = _db;
        }

        private void uxSpeichernBtn_Click(object sender, RoutedEventArgs e)
        {
            _db.Speichern();
            this.Close();
        }

        private void uxAbbrechenBtn_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void TextBox_KeyDown(object sender, KeyEventArgs e)
        {
            //Prüfen das es sich nur um Zahlen handelt bei der Eingabe
            if (!(Keyboard.IsKeyDown(Key.D0) || Keyboard.IsKeyDown(Key.D1) || Keyboard.IsKeyDown(Key.D2) || Keyboard.IsKeyDown(Key.D3) || Keyboard.IsKeyDown(Key.D4)
                || Keyboard.IsKeyDown(Key.D5) || Keyboard.IsKeyDown(Key.D6) || Keyboard.IsKeyDown(Key.D7) || Keyboard.IsKeyDown(Key.D8) || Keyboard.IsKeyDown(Key.D9)))            {
                e.Handled = true;
            }
        }
    }
}
